package com.example.service.impl;


import com.example.dao.TeacherDao;
import com.example.dao.UserDao;
import com.example.entity.Goods;
import com.example.entity.User;
import com.example.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Collections;
import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private TeacherDao teacherDao;
    @Override
    public User getTeacherByAuthor(int gid) {
        return teacherDao.findByAuthor(gid);
    }

    @Override
    public User getTeacherByUid(int uid) {
        return userDao.findById(uid);
    }


    @Override
    public List<Goods> getGoodsByTeacherName(String name) {
        // 调用 DAO 层的方法查询商品信息
        return teacherDao.getGoodsByTeacherName(name);
    }

    @Override
    public Goods getGoodsById(Integer gid) {
        return teacherDao.findById(gid);
    }

    @Override
    public List<Goods> getAllGoods() {
        return teacherDao.findAll();
    }

    @Override
    public boolean addGoods(Goods goods) {
        return teacherDao.insert(goods) > 0;
    }

    @Override
    public boolean updateGoods(Goods goods) {
        return teacherDao.update(goods) > 0;
    }

    @Override
    public boolean deleteGoods(Integer gid) {
        return teacherDao.delete(gid) > 0;
    }




}
